package com.tianyang.yukuaifuzs.business.main.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifuzs.R;
import com.tianyang.yukuaifuzs.business.main.bean.PosUserOutput;
import com.tianyang.yukuaifuzs.module.roundview.RoundTextView;
import com.tianyang.yukuaifuzs.utils.VerifyUtil;

import java.util.ArrayList;

/**
 * Description：商户管理
 * Created by xyj on 2024/3/10
 */
public class MerchantManageAdapter extends BaseQuickAdapter<PosUserOutput, BaseViewHolder> {

    public MerchantManageAdapter() {
        super(R.layout.item_merchant_manage, new ArrayList<>());
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PosUserOutput item) {
        if (item != null) {
            helper.setText(R.id.merchantNameTv, VerifyUtil.checkString(item.getMerchantName()))
                    .setText(R.id.createTimeTv, "入网日期："+VerifyUtil.checkString(item.getCreateDate()))
                    .addOnClickListener(R.id.copyPtRtv, R.id.copyMchRtv, R.id.copyPhoneRtv)
                    .setText(R.id.nameTv, "证件名称："+item.getName())
                    .setText(R.id.bangdingcommercodeTv, item.getBangdingcommercode())
                    .setText(R.id.mchIdTv, item.getMchId())
                    .setText(R.id.phoneTv, item.getPhone())
                    .setText(R.id.devicesNumberTv, "设备数量："+item.getDevicesNumber())
                    .setText(R.id.settleCycleNameTv, "结算方式："+item.getSettleCycleName());
            RoundTextView statusTv = helper.getView(R.id.isAuthRtv);
            if (!TextUtils.equals("已完成", item.getStatus())) {
                statusTv.setText(VerifyUtil.checkString(item.getStatus()));
                statusTv.setTextColor(ContextCompat.getColor(mContext, R.color.c_999999));
                statusTv.getDelegate().setStrokeColor(ContextCompat.getColor(mContext, R.color.c_999999));
            } else {
                statusTv.setText("已入网");
                statusTv.setTextColor(ContextCompat.getColor(mContext, R.color.color_base));
                statusTv.getDelegate().setStrokeColor(ContextCompat.getColor(mContext, R.color.color_base));
            }
            TextView mchTypeTv = helper.getView(R.id.mchTypeTv);
            switch (item.getMchType()) {
                case 0:
                    mchTypeTv.setText("商户类型：企业商户");
                    break;
                case 1:
                    mchTypeTv.setText("商户类型：小微商户");
                    break;
                case 2:
                    mchTypeTv.setText("商户类型：个体商户");
                    break;
            }
        }
    }
}
